<?php

namespace app\helpers;

use app\models\Setting;

class SettingHelper {

    const cacheKey = '__settings';

    protected static $settings = [];

    protected static function init() {
        $model = new Setting();
        self::$settings = $model->access();
    }

    public static function get($name, $default = NULL) {
        if (empty(self::$settings)) {
            self::init();
        }
        if (isset(self::$settings[$name]) && !empty(self::$settings[$name])) {
            return self::$settings[$name];
        }
        return $default;
    }
}